package com.sgcc.lms;

import com.alibaba.fastjson.parser.JSONToken;
import com.alibaba.nacos.api.NacosFactory;
import com.alibaba.nacos.api.config.ConfigService;
import com.alibaba.nacos.api.config.listener.Listener;
import com.alibaba.nacos.api.exception.NacosException;
import com.alibaba.nacos.api.naming.pojo.Instance;
import com.alibaba.nacos.api.naming.pojo.ListView;
import com.alibaba.nacos.api.naming.pojo.ServiceInfo;
import com.alibaba.nacos.client.naming.NacosNamingService;

import java.util.List;
import java.util.Properties;
import java.util.Scanner;
import java.util.concurrent.Executor;

/**
 * @Author: 李孟帅
 * @CreateTime: 2020-05-22 15:29
 * @Description:
 */
public class NacoClientTest {
    public static void main(String[] args) throws NacosException {
        Properties properties = new Properties();
//        properties.put("serverAddr","127.0.0.1:8849,127.0.0.1:8850,127.0.0.1:8851");
        properties.put("serverAddr","192.100.3.28:9000");

        String dataId="log.properties";
        String group="DEFAULT_GROUP";
        ConfigService configService = NacosFactory.createConfigService(properties);
        String config = configService.getConfig(dataId, group, 5000);
        System.out.println(configService.getServerStatus());
        System.out.println(config);


//        NacosNamingService namingService = new NacosNamingService(properties);
//        System.out.println(namingService.getServerStatus());
//        ListView<String> servicesOfServer = namingService.getServicesOfServer(1, 10);
//        servicesOfServer.getData().forEach(System.out::println);
//        List<Instance> allInstances = namingService.getAllInstances("px-common-gateway");
//        allInstances.forEach(System.out::println);

//        new Scanner(System.in).nextLine();
    }
}
